/**
 * 作者: wgx
 * 日期: 2024-10-15 14:03:33
 * 备注: 干员伙伴表
 */
package com.motu.monstercity.server.game.commondata.partner;
import com.motu.monstercity.server.game.base.CommonUtils;
import com.motu.monstercity.server.game.commondata.skill.Skill;
import com.motu.monstercity.server.game.commondata.skill.SkillConstant;
import com.motu.monstercity.server.game.logic.PartnerManager;
import com.motu.monstercity.server.game.logic.SkillManager;
import com.motu.vertx.module.utility.toolset.Tool;
import io.vertx.core.json.JsonArray;
import io.vertx.core.json.JsonObject;

public class PartnerMain extends PartnerMainModel {
    public PartnerMain(JsonObject obj) {
        super(obj);
    }

    // 基础技能
    public int[] takeSkillBaseList() {
        if (Tool.isEmpty(getSkillBase())) {
            return null;
        }
        return CommonUtils.strToIntArray(getSkillBase());
    }

    // 大世界技能
    public int[] takeSkillWorldList() {
        if (Tool.isEmpty(getSkillWorld())) {
            return null;
        }
        return CommonUtils.strToIntArray(getSkillWorld());
    }

    // 专属技能
    public int[] takeSkillExStuntList() {
        if (Tool.isEmpty(getSkillExStunt())) {
            return null;
        }
        return CommonUtils.strToIntArray(getSkillExStunt());
    }

    // 光环技能列表
    public int[] takeSkillHaloList() {
        if (Tool.isEmpty(getSkillHalo())) {
            return null;
        }
        return CommonUtils.strToIntArray(getSkillHalo());
    }

    //  光环技能会影响到的其他干员, 某个性格的所有干员，和自己能组成光环的干员
    public JsonArray takeHaloPartnerIds() {
        JsonArray jsonArray = new JsonArray();
        int[] haloSkillList = takeSkillHaloList();
        if (haloSkillList != null && haloSkillList.length > 0) {
            for (int i=0; i<haloSkillList.length; i++) {
                int skillId = haloSkillList[i];
                Skill skill = SkillManager.getSkill(skillId);
                if (skill != null && skill.getEffectType() == SkillConstant.EFFECT_TYPE_45) {
                    for (PartnerMain partnerMain : PartnerManager.getPartnerMainMap().values()) {
                        if (partnerMain.getCharacterType() == skill.getEffectParam() && getPartnerId() != partnerMain.getPartnerId()) {
                            jsonArray.add(partnerMain.getPartnerId());// 排除掉自己
                        }
                    }
                }
            }
        }
        PartnerHalo partnerHalo = PartnerManager.getPartnerHaloByPartnerId(getPartnerId());
        if (partnerHalo != null && partnerHalo.takePartnerIs() != null) {
            int[] list = partnerHalo.takePartnerIs();// // 排除掉自己
            for (int i=0; i<list.length; i++) {
                int aa = list[i];// 干员Id
                if (getPartnerId() != aa && !Tool.isInList(jsonArray, aa)) {
                    jsonArray.add(aa);
                }
            }
        }

        return jsonArray;
    }
}
